﻿using Microsoft.AspNetCore.Mvc;
using MVC_System.DTO.Reservoir;
using MVC_System.DTO.ReturnWarehouse;
using MVC_System.DTO.Warehouse;
using WMS_MAV;

namespace MVC_System.Controllers
{
    public class ReturnWarehouseController: Controller
    {
        protected readonly IConfiguration _configuration;

        public ReturnWarehouseController(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        /// <summary>
        /// 返库添加
        /// </summary>
        /// <returns></returns>
        public IActionResult ReturnWarehouseAdd()
        {
            return View();
        }
        /// <summary>
        /// 返库显示
        /// </summary>
        /// <returns></returns>
        public IActionResult ReturnWarehouseShow()
        {
            return View();
        }
        /// <summary>
        /// 返库详情
        /// </summary>
        /// <returns></returns>
        public IActionResult ReturnWarehouseDetails()
        {
            return View();
        }

        /// <summary>
        /// 返库信息API
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<ActionResult> LedgerInfoReturnWarehouseAdd(ReturnWarehouseAddDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "mhb/api/ReturnWarehouse/ReturnWarehouseAdd";
            var respomse = await client.PostAsync(url, dto.Data);
            return Json(respomse);
        }
        /// <summary>
        /// 库区管理显示列表
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> LedgerInfoReturnWarehouseShow(ReturnWarehouseShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "mhb/api/ReturnWarehouse/ReturnWarehouseShow?pageiden="+ dto.pageindex + "&pageSzen="+ dto.pagesize + "&outboundNumber="+ dto.outboundNumber + "&AddTime="+ dto .AddTime+ "&returnStatus="+ dto.returnStatus;
            var response = await client.GetAsync(url);
            return Json(response);
        }
    }
}
